Read Attribute values fropm another module

Hi,

I've been using DOORS for a while, modifying standard dxlscripts etc, but my experience of writing from scratch is zero and I'm struggling.

I have 2 separate modules and I want to use the value of an enumerated field in Module A to read the data/values from attribute2 and attribute3 in Module B where the ennumerated field value in Module A matches in with attribute1 in Module B and insert those values in 2 separate fields in Module A using dxl.

If anybody can help me with the script I would be very grateful.

Thanks

Paul
SystemAdmin - Thu Jan 10 09:12:43 EST 2013

Re: Read Attribute values fropm another module
llandale - Thu Jan 10 10:42:17 EST 2013

It seems to me this makes sense only if an object in A is related to an object in B; presumably via a link.

  • From oA you would follow the link and find oB.
  • ValueA = oA."My Single Enum Attr"
  • AttrDef ad = find(mB, ValueA)
  • if (null ad)
  • then the value in A does not correspond to an attribute in B
  • else ValueDesired = oB.ValueA

If B has a multi-enumerated attr then that doesn't make sense to me, and it gets a lot trickier parsing Bs value.

-Louie

Re: Read Attribute values fropm another module
SystemAdmin - Fri Jan 11 11:27:18 EST 2013

llandale - Thu Jan 10 10:42:17 EST 2013
It seems to me this makes sense only if an object in A is related to an object in B; presumably via a link.

  • From oA you would follow the link and find oB.
  • ValueA = oA."My Single Enum Attr"
  • AttrDef ad = find(mB, ValueA)
  • if (null ad)
  • then the value in A does not correspond to an attribute in B
  • else ValueDesired = oB.ValueA

If B has a multi-enumerated attr then that doesn't make sense to me, and it gets a lot trickier parsing Bs value.

-Louie

I can see that I haven't worded my request correctly, I should have inserted the word value between 'attribute1' and 'in Module B'.

Question should ahve been "I have 2 separate modules and I want to use the value of an enumerated field in Module A to read the data/values from attribute2 and attribute3 in Module B where the ennumerated field value in Module A matches in with attribute1 value in Module B and insert those values in 2 separate fields in Module A using dxl. "

Basically I want to loop through all the objects in Module B, find the value in attribute1 that matches the ennumerated value and then copy values across from module B to module A in the same way as a link would but without using a link.

This is as far as I have got

pragma runLim, 0

ModName_ srcMod = module("/7_UserSandboxes/mcmaho_p/AIDA2/Meetings")

Module destMod = current

Object o2, o1

//http://www.ibm.com/developerworks/forums/thread.jspa?threadID=455130

for o1 in destMod do
{
string eValue1 = o1."Meeting#"
for o2 in srcMod do
{
string eValue2 = o2."Reference Number"
if (eValue1 == eValue2){print "\n" eValue1 " matches"}
}
}

But I get an error on the 2nd do loop.

Thanks

Paul

Re: Read Attribute values fropm another module
Mathias Mamsch - Fri Jan 11 12:29:19 EST 2013

SystemAdmin - Fri Jan 11 11:27:18 EST 2013
I can see that I haven't worded my request correctly, I should have inserted the word value between 'attribute1' and 'in Module B'.

Question should ahve been "I have 2 separate modules and I want to use the value of an enumerated field in Module A to read the data/values from attribute2 and attribute3 in Module B where the ennumerated field value in Module A matches in with attribute1 value in Module B and insert those values in 2 separate fields in Module A using dxl. "

Basically I want to loop through all the objects in Module B, find the value in attribute1 that matches the ennumerated value and then copy values across from module B to module A in the same way as a link would but without using a link.

This is as far as I have got

pragma runLim, 0

ModName_ srcMod = module("/7_UserSandboxes/mcmaho_p/AIDA2/Meetings")

Module destMod = current

Object o2, o1

//http://www.ibm.com/developerworks/forums/thread.jspa?threadID=455130

for o1 in destMod do
{
string eValue1 = o1."Meeting#"
for o2 in srcMod do
{
string eValue2 = o2."Reference Number"
if (eValue1 == eValue2){print "\n" eValue1 " matches"}
}
}

But I get an error on the 2nd do loop.

Thanks

Paul

If you look for "link by attribute" you will probably find a large part of the code you need. Instead of making a link you insert your code for copying the attribute values. Maybe that helps, regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: Read Attribute values fropm another module
llandale - Fri Jan 11 16:26:24 EST 2013

SystemAdmin - Fri Jan 11 11:27:18 EST 2013
I can see that I haven't worded my request correctly, I should have inserted the word value between 'attribute1' and 'in Module B'.

Question should ahve been "I have 2 separate modules and I want to use the value of an enumerated field in Module A to read the data/values from attribute2 and attribute3 in Module B where the ennumerated field value in Module A matches in with attribute1 value in Module B and insert those values in 2 separate fields in Module A using dxl. "

Basically I want to loop through all the objects in Module B, find the value in attribute1 that matches the ennumerated value and then copy values across from module B to module A in the same way as a link would but without using a link.

This is as far as I have got

pragma runLim, 0

ModName_ srcMod = module("/7_UserSandboxes/mcmaho_p/AIDA2/Meetings")

Module destMod = current

Object o2, o1

//http://www.ibm.com/developerworks/forums/thread.jspa?threadID=455130

for o1 in destMod do
{
string eValue1 = o1."Meeting#"
for o2 in srcMod do
{
string eValue2 = o2."Reference Number"
if (eValue1 == eValue2){print "\n" eValue1 " matches"}
}
}

But I get an error on the 2nd do loop.

Thanks

Paul

The only failing I see in your code is that destMod = current should be BEFORE you open the srcMod; as opening that module may make it the "current" one. Add this and I think you'll see both are the same:

  • print "Dest/Srce = " name(destMod) "\t" name(srcMod) "\n"


Now that I think of it, I suppose you WOULD get an error if both modules were the same since you have nested the same Object loop.

In any event, it would run a LOT faster if you staged the values of srcMod in a Skip:

 

Skip skpSrcMod = createString() // KEY 'string' Ref; DATA: 'Object' with that Ref
for o2 in srcMod do
{  put(skpSrcMod, o2."Reference Number" "", o2)
}
for o1 in destMod do
{  eValue1 = o1."Meeting#"
   if (find(skpSrcMod, eValue1, o2) then print eValue1 "\tMatches between " identifier(o1) "\tand  " identifier(o2) "\n"
}
delete skpSrcMod



-Louie



 

Re: Read Attribute values fropm another module
SystemAdmin - Sat Jan 12 15:54:55 EST 2013

llandale - Fri Jan 11 16:26:24 EST 2013

The only failing I see in your code is that destMod = current should be BEFORE you open the srcMod; as opening that module may make it the "current" one. Add this and I think you'll see both are the same:

  • print "Dest/Srce = " name(destMod) "\t" name(srcMod) "\n"


Now that I think of it, I suppose you WOULD get an error if both modules were the same since you have nested the same Object loop.

In any event, it would run a LOT faster if you staged the values of srcMod in a Skip:

 

Skip skpSrcMod = createString() // KEY 'string' Ref; DATA: 'Object' with that Ref
for o2 in srcMod do
{  put(skpSrcMod, o2."Reference Number" "", o2)
}
for o1 in destMod do
{  eValue1 = o1."Meeting#"
   if (find(skpSrcMod, eValue1, o2) then print eValue1 "\tMatches between " identifier(o1) "\tand  " identifier(o2) "\n"
}
delete skpSrcMod



-Louie



 

I've updated my code to

pragma runLim, 0

Module destMod = current

ModName_ srcMod = module("/7_UserSandboxes/mcmaho_p/AIDA2/Meetings")

Object o2, o1

//http://www.ibm.com/developerworks/forums/thread.jspa?threadID=455130

Skip skpSrcMod = createString() // KEY 'string' Ref; DATA: 'Object' with that Ref
for o2 in srcMod do{
put(skpSrcMod, o2."Reference Number" "", o2)
}

for o1 in destMod do{
string eValue1 = o1."Meeting#"
if (find(skpSrcMod, eValue1, o2) then print eValue1 "\tMatches between " identifier(o1) "\tand " identifier(o2) "\n"
}
delete skpSrcMod

but I get 2 errors:

-E- DXL: <Line:12> incorrect arguments for (do)
-E- DXL: <Line:18> syntax error
-I- DXL: All done. Errors reported: 2. Warnings reported: 0.

Thanks

Paul

Re: Read Attribute values fropm another module
SystemAdmin - Mon Jan 14 08:49:28 EST 2013

SystemAdmin - Sat Jan 12 15:54:55 EST 2013
I've updated my code to

pragma runLim, 0

Module destMod = current

ModName_ srcMod = module("/7_UserSandboxes/mcmaho_p/AIDA2/Meetings")

Object o2, o1

//http://www.ibm.com/developerworks/forums/thread.jspa?threadID=455130

Skip skpSrcMod = createString() // KEY 'string' Ref; DATA: 'Object' with that Ref
for o2 in srcMod do{
put(skpSrcMod, o2."Reference Number" "", o2)
}

for o1 in destMod do{
string eValue1 = o1."Meeting#"
if (find(skpSrcMod, eValue1, o2) then print eValue1 "\tMatches between " identifier(o1) "\tand " identifier(o2) "\n"
}
delete skpSrcMod

but I get 2 errors:

-E- DXL: <Line:12> incorrect arguments for (do)
-E- DXL: <Line:18> syntax error
-I- DXL: All done. Errors reported: 2. Warnings reported: 0.

Thanks

Paul

You're getting an error in the for loop, because srcMod is of type ModName_...that's a reference to the name of a module, not the module itself

The for loop should use an attribute of type Module

Change

ModName_ srcMod = module("/7_UserSandboxes/mcmaho_p/AIDA2/Meetings")

To

 

Module srcMod = read("/7_UserSandboxes/mcmaho_p/AIDA2/Meetings", false)
if (null(srcMod)) halt // failed to open module for reading


You're also missing a close-brace on line 18

 

if (find(skpSrcMod, eValue1, o2) then print eValue1 "\tMatches between " identifier(o1) "\tand " identifier(o2) "\n"

becomes

 

if (find(skpSrcMod, eValue1, o2)) then print eValue1 "\tMatches between " identifier(o1) "\tand " identifier(o2) "\n"